home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Development Tools & Languages / DTSCPlusLibrary / Sources / Toolbox.cp < prev    next >
Encoding:
Text File  |  1993-01-14  |  2.6 KB  |  101 lines  |  [TEXT/MPS ]

  1. /* _________________________________________________________________________________________________________ //
  2.   Copyright © 1992-93 Apple Computer, Inc. All rights reserved.
  3.   Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
  4.   Programmer: Kent Sandvik
  5.   Date: Saturday, June 6, 1992 19:18:58
  6.   Revision comments are at the end of this file.
  7.   ---
  8.   TToolbox is a Toolbox utility class, used for initialization and Toolbox functions.
  9.   TToolbox.cp contains the class body information for the TToolbox member functions.
  10.   _________________________________________________________________________________________________________ */
  11.  
  12.  
  13. // Include files
  14. #ifndef _TOOLBOX_
  15. #include "Toolbox.h"
  16. #endif
  17.  
  18.  
  19. // _________________________________________________________________________________________________________ //
  20. // TToolbox class member function implementations
  21. //    CONSTRUCTORS & DESTRUCTORS
  22. #pragma segment Toolbox                   
  23. TToolbox::TToolbox()
  24. // Default constructor.
  25. {
  26. }
  27.  
  28.  
  29. #pragma segment Toolbox
  30. TToolbox::~TToolbox()
  31. // Virtual destructor, we are not doing anything inside this one just now, note 
  32. // that virtual destructors should not be inlined
  33. {
  34. }
  35.  
  36.  
  37. //    INITIATION ROUTINES
  38. #pragma segment Toolbox
  39. void TToolbox::InitializeToolbox()
  40. // Initialize the Macintosh Toolbox environment, standard initialization routines.
  41. {
  42.     ::InitGraf(&qd.thePort);
  43.     ::InitFonts();
  44.     ::InitWindows();
  45.     ::InitMenus();
  46.     ::TEInit();
  47.     ::InitDialogs(NULL);
  48.     ::InitCursor();
  49. }
  50.  
  51.  
  52. // MAIN INTERFACE
  53. #pragma segment Toolbox
  54. void TToolbox::PullApplicationToFront(short nCount)
  55. // Make sure that any possible splash screens are placed front-most.
  56. {
  57.     EventRecord anEvent;
  58.     short aCount;
  59.  
  60.     for (aCount = 1; aCount <= nCount; aCount++)        // pluck out a couple of events until things are OK
  61.         ::EventAvail(everyEvent, &anEvent);
  62. }
  63.  
  64.  
  65. #pragma segment Toolbox
  66. Boolean TToolbox::CreateMasterPointers(short nMasterPtr)
  67. // Create n amount of Master Pointers.
  68. {
  69.     OSErr anErr;
  70.  
  71.     while (nMasterPtr--)
  72.         ::MoreMasters();
  73.  
  74.     anErr = MemError();
  75.     VASSERT(anErr == noErr, ("Problems with MoreMasters = %d", anErr));
  76.     
  77.     if(anErr == noErr)
  78.         return true;
  79.     else
  80.         return false;            // we had problems, and signal this
  81. }
  82.  
  83.  
  84. #pragma segment Toolbox
  85. void TToolbox::Initialize()
  86. // Default initialization of Toolbox routines.
  87. {
  88.     this->InitializeToolbox();
  89.     this->CreateMasterPointers();
  90.     this->PullApplicationToFront();
  91. }
  92.  
  93.  
  94. // _________________________________________________________________________________________________________ //
  95.  
  96. /*    Change History (most recent last):
  97.   No        Init.    Date        Comment
  98.   1            khs        6/6/92        New file
  99.   2            khs        1/3/93        Cleanup
  100. */
  101.